package com.neusoft.springboot07.controller;

import com.github.pagehelper.PageInfo;
import com.neusoft.springboot07.domain.TItem;
import com.neusoft.springboot07.service.ItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class TitemController {

    @Autowired
    private ItemsService itemsService;

    @RequestMapping("/findByPage.do")
    @ResponseBody
    public PageInfo<TItem> findPageByitem(Integer pno,Integer ps)
    {
        return itemsService.queryUserByPage(pno,ps);
    }

    @RequestMapping("findbyPageForItem.do")
    public ModelAndView findByPage(Integer pno,Integer ps)
    {
        ModelAndView modelAndView = new ModelAndView("view/itemlist");
        PageInfo<TItem> pageInfo = itemsService.queryUserByPage(pno,ps);
        modelAndView.addObject("page",pageInfo);
        return modelAndView;
    }
}
